package org.example.B3;



import com.github.oxo42.stateless4j.delegates.FuncBoolean;

public class GuardCondition {
    private StringBuilder extractedString;             // 存储提取到的字符串
    private char currentChar;               // 当前正在读取的字符串
    private int quoteCnt = 0; //记录第几个双引号
    private int backslashCnt = 0; //记录反斜杠

    /**
     * 当遇到第一个双引号时
     */
    FuncBoolean when_firstQuote(){
        return() -> (currentChar == '\"' && quoteCnt == 0);
    }

    /**
     * 遇到第二个双引号时
     */
    FuncBoolean when_secondQuote(){
        return() -> (currentChar == '\"' && quoteCnt == 1);
    }

    /**
     * 遇到反斜杠
     */
    FuncBoolean when_backslash(){
        return() -> (currentChar == '\\' && backslashCnt == 0);
    }

    FuncBoolean when_other(){
        return() -> (currentChar != '\"' && currentChar != '\\');
    }

    void setExtractedString(StringBuilder extractedString) {
        this.extractedString = extractedString;
    }

    void setCurrentChar(char currentChar) {
        this.currentChar = currentChar;
    }

    void setQuoteCnt(int quoteCnt) {
        this.quoteCnt = quoteCnt;
    }

    void setBackslashCnt(int backslashCnt) {
        this.backslashCnt = backslashCnt;
    }
}

